package com.xufang.demo;

import redis.clients.jedis.Jedis;

import java.util.List;

public class Demo3 {
    public static void main(String[] args) {
    
        Jedis jedis = new Jedis("192.168.137.103", 6379);
        
        // List 添加
        Long lpush = jedis.lpush("list", "111", "222","333");
        System.out.println("总条数: "+lpush);
        
        // 通过下标位置访问
        String name = jedis.lindex("list", 1);
        System.out.println(name);
        
        // 遍历
        List<String> stringList = jedis.lrange("list", 0, 2);
    
        for (String s : stringList) {
            System.out.println(s);
        }
    
        // 释放资源
        jedis.close();
    }
}
